//
//  AppDelegate.m
//  SinaWeibo
//
//  Created by Apple on 16/8/6.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "AppDelegate.h"
#import "MainViewController.h"
#import "HomeViewController.h"
#import "MessageViewController.h"
#import "DiscoverViewController.h"
#import "ProfileViewController.h"
#import "WelcomeViewController.h"
#import "WelcomeBackViewController.h"
#import "AcountModel.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    /**
     *  初始化ddlog
     */
    [DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console
    [DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs
    
    //日志保留日起
//    DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger
//    fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
//    fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
//    [DDLog addLogger:fileLogger];
    


    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    [self.window makeKeyAndVisible];
    
    WelcomeBackViewController *welcomeBackVC = [[WelcomeBackViewController alloc]init];

//根据沙盒里的acount是否为空来判断
    //1.获取来自沙盒的对象
    AcountModel *acountModel = [AcountModel acountModelFromSandbox];
    
    if (acountModel != nil) {
    
        [self.window chooseRootViewController];

    }else{
        
        self.window.rootViewController = welcomeBackVC;
    }

    return YES;
}

-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application{
    
    [[SDWebImageManager sharedManager] cancelAll];
    
    [[SDWebImageManager sharedManager].imageCache clearMemory];
    
    
}




@end
